<?php
//Nush ce sa adaug, dar am adaugat-o pt viitor


require("../config.php");


class base{
        /*Friends functions*/
	function get_id($user){
	global $db;
        $q=$db->query("SELECT id FROM users WHERE user='$user' LIMIT 1");
	if(mysql_num_rows($q)==0){return false;}
            else{
                $r=mysql_fetch_array($q);return $r['id'];
            }
        }
        function friend_add($uid_cur,$uid_add){
            global $db;
            //$db->query("INSERT INTO events VALUES()");
            if(mysql_num_rows($db->query("INSERT INTO friends_rep VALUES($uid_cur,$uid_add,0)")) >0)
                return true;
            
            return false;
        }
        function friend_rel($uid_cur,$uid_add,$rel){
            global $db;
            //0 - pending, 1 - accept, 2 - deny ,3 - ignore
            if(mysql_num_rows( $db->query("UPDATE friends_rep SET tip=$rel WHERE uid_cur=$uid_cur AND uid_add=$uid_add LIMIT 1")) >0)
                    return true;
            return false;
        }
        function friend_sts($uid,$sts){
            global $db;
            if(strlen($sts)<40){
             if(mysql_num_rows( $db->query("UPDATE friends_settings SET sts='$sts' WHERE uid=$uid LIMIT 1")) >0)
                     return true;
             return false;
            }
            return false;
        }

}


?>